<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>React02</title>

</head>

<body>
  <div class="container">

  </div>

  <!-- react核心库 -->
  <script src="./js/react.development.js"></script>
  <!-- react拓展库 用于支持react操作dom -->
  <script src="./js/react-dom.development.js"></script>
  <script src="./js/babel.min.js"></script>

  <script type="text/babel">
    class Weather extends React.Component {
      constructor(props) {
        super(props)
      }

      state = {
        isHot: true
      }

      // 挂在到实例自身
      changeWeather = () => {
        console.log(this)
        const { isHot } = this.state
        this.setState({ isHot: !isHot })
      }

      render() {
        const { isHot } = this.state
        return (
          <p onClick={this.changeWeather}>今天天气很{isHot ? '炎热' : '凉爽'}</p>
        )
      }
    }

    ReactDOM.render(<Weather />, document.querySelector('.container'))
  </script>
</body>

</html>